package com.yunji.framework_template.books.web.controller;
import com.yunji.framework_template.books.orm.persistence.model.BooksUserLike;
import com.yunji.framework_template.books.biz.service.BooksUserLikeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yunji.framework_template.common.web.Result;
import com.yunji.framework_template.common.web.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by fenglibin on 2019/01/24.
 */
@Controller
@RequestMapping("/booksUserLike/")
public class BooksUserLikeController {

    @Autowired
    BooksUserLikeService booksUserLikeService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<BooksUserLike>> selectAll(){
        return Result.success(booksUserLikeService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<BooksUserLike> selectByPrimaryKey(Integer id){
        return Result.success(booksUserLikeService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<BooksUserLike>> selectByCondition(BooksUserLike record){
        return Result.success(booksUserLikeService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(BooksUserLike record){
        return Result.success(booksUserLikeService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(BooksUserLike record){
        return Result.success(booksUserLikeService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(BooksUserLike record){
        return Result.success(booksUserLikeService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<BooksUserLike>>> selectByPage(Page<BooksUserLike> page){
        List<BooksUserLike> list = null;
        page = page.sequentialDisplayCalculate(booksUserLikeService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = booksUserLikeService.selectByPage(page);
        }
        Page<List<BooksUserLike>> result = new Page<List<BooksUserLike>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(BooksUserLike record){
        return Result.success(booksUserLikeService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id){
        return Result.success(booksUserLikeService.deleteByPrimaryKey(id));
    }

}
